﻿<Window 
    x:Class="Bindable.Linq.SampleApplication.Samples.SyncLinqGroupedWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:test="clr-namespace:Bindable.Linq.SampleApplication"
    Title="Bindable LINQ Example - Grouping" 
    Width="800"
    Height="600" 
    x:Name="_this"
    Background="{StaticResource Brush_DarkLightDarkLightBlue}"
    WindowState="Maximized"
    >
    <Window.CommandBindings>
        <CommandBinding Command="{x:Static test:Commands.Refresh}" Executed="RefreshCommand_Executed" />
        <CommandBinding Command="{x:Static test:Commands.Delete}" Executed="DeleteCommand_Executed" />
        <CommandBinding Command="{x:Static test:Commands.Add}" Executed="AddCommand_Executed" />
    </Window.CommandBindings>
    <Window.InputBindings>
        <KeyBinding Command="{x:Static test:Commands.Refresh}" Key="F5" />
        <KeyBinding Command="{x:Static test:Commands.Add}" Key="Add" />
        <KeyBinding Command="{x:Static test:Commands.Delete}" Key="Delete" />
    </Window.InputBindings>

    <Window.Resources>

        <DataTemplate x:Key="Local_ContactGroupTemplate">
            <Border 
                BorderBrush="{StaticResource Brush_GroupBorder}" 
                CornerRadius="5" 
                BorderThickness="1,1,0,0"
                Margin="7,7,7,0"
                Background="{StaticResource Brush_GroupBackground}"
                >
                <Border 
                    BorderBrush="{StaticResource Brush_GroupBorderInside}"  
                    BorderThickness="1,1,0,0" 
                    CornerRadius="5"
                    >
                    <StackPanel>
                        <DockPanel>
                            <TextBlock
                                DockPanel.Dock="Left"
                                Width="32"
                                TextAlignment="Center"
                                FontSize="12pt"
                                Margin="14,14,0,0"
                                Text="{Binding Path=NameLengths.Value}"
                                Foreground="#2F79B4"
                                />
                            <TextBlock 
                                Text="{Binding Path=Company}" 
                                Foreground="#2F79B4"
                                FontSize="12pt"
                                Margin="14,14,0,0"
                                />
                        </DockPanel>

                        <ListBox
                            Margin="7"
                            Style="{StaticResource ContactTemplate_ListBoxStyle}"
                            ItemsSource="{Binding Path=Contacts}"
                            ItemContainerStyle="{StaticResource ContactTemplate_EditableContactListBoxItemStyle}"
                            ItemTemplate="{StaticResource ContactTemplate_EditableContactDataTemplate}"
                            KeyboardNavigation.DirectionalNavigation="Continue"
                            />
                    </StackPanel>
                </Border>
            </Border>
        </DataTemplate>

    </Window.Resources>

    <!-- 
    Content of the window 
    -->
    <DockPanel 
        Margin="7"
        >
        <!-- 
        Window title
        -->
        <Border
            DockPanel.Dock="Top"
            >
            <TextBlock 
                Style="{StaticResource App_TitleText}"
                Margin="7"
                >
                Bindable LINQ Example - Grouping
            </TextBlock>
        </Border>

        <!--
        Contents
        -->
        <Border 
            Background="{StaticResource App_BackgroundBrush}"
            Margin="7"
            CornerRadius="7"
            Padding="7"
            BorderThickness="1"
            BorderBrush="#FFFFFF"
            >
            <DockPanel>
                <!--
                Toolbar
                -->
                <Border 
                    DockPanel.Dock="Top"
                    Margin="7"
                    Style="{StaticResource Toolbar_BorderStyle}"
                    >
                    <DockPanel Margin="3.5">
                        <Label
                            Margin="3.5"
                            Style="{StaticResource Toolbar_ControlLabelStyle}"
                            DockPanel.Dock="Left"
                            >
                            Name:
                        </Label>
                        <TextBox
                            Width="150"
                            Text="{Binding ElementName=_this, Path=NewContact.Name}"
                            VerticalContentAlignment="Center"
                            DockPanel.Dock="Left"
                            Margin="3.5"
                            />
                        <Label
                            Margin="3.5"
                            Style="{StaticResource Toolbar_ControlLabelStyle}"
                            DockPanel.Dock="Left"
                            >
                            Company:
                        </Label>
                        <TextBox
                            Width="210"
                            Text="{Binding ElementName=_this, Path=NewContact.Company}"
                            x:Name="_newContactEmailTextBox"
                            VerticalContentAlignment="Center"
                            DockPanel.Dock="Left"
                            Margin="3.5"
                            />
                        <Button 
                            Margin="3.5" 
                            Style="{StaticResource Toolbar_ButtonStyle}"
                            Command="{x:Static test:Commands.Add}" 
                            DockPanel.Dock="Left"
                            >
                            Add
                        </Button>
                        <Button
                            Style="{StaticResource Toolbar_ButtonStyle}"
                            Margin="3.5"
                            Command="{x:Static test:Commands.Refresh}"
                            DockPanel.Dock="Left"
                            >
                            Refresh
                        </Button>

                        <Label
                            Margin="3.5"
                            Style="{StaticResource Toolbar_NotifictionMessageBorderStyle}"
                            IsEnabled="False"
                            >
                            Retrieving items, please wait...
                        </Label>
                    </DockPanel>
                </Border>

                <ScrollViewer>
                    <!-- 
                    Contacts list box
                    -->
                    <ItemsControl
                        ItemsSource="{Binding }"
                        ItemTemplate="{StaticResource Local_ContactGroupTemplate}"
                        >

                    </ItemsControl>
                </ScrollViewer>

            </DockPanel>
        </Border>

    </DockPanel>

</Window>
